package API.DateDome.LocalDateTimeDome;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * ClassName:LocalDateTimeText005
 * Package:API.DateDome.LocalDateTimeDome
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/2-19:17
 * @Version:v1.0
 */
public class LocalDateTimeDome {
    /*LocalDateTime：年月日 时分秒*/
    public static void main(String[] args) {
        //获取当前时间的时分秒
        LocalDateTime nowLocalDateTime = LocalDateTime.now();
        System.out.println("今天是："+nowLocalDateTime);

        System.out.println("年："+nowLocalDateTime.getYear());
        System.out.println("月："+nowLocalDateTime.getDayOfMonth());
        System.out.println("日："+nowLocalDateTime.getDayOfWeek());
        System.out.println("时："+nowLocalDateTime.getHour());

        //星期
        System.out.println(nowLocalDateTime.getDayOfWeek());
        System.out.println(nowLocalDateTime.getDayOfWeek().getValue());

        //获取年月日
        LocalDate localDate = nowLocalDateTime.toLocalDate();
        System.out.println(localDate);//2023-02-02
        //获取时分秒
        LocalTime localTime = nowLocalDateTime.toLocalTime();
        System.out.println(localTime);
        System.out.println(localTime.getHour());
        System.out.println(localTime.getMinute());
        System.out.println(localTime.getSecond());
    }
}
